package com.upf1sh.config;

//import com.upf1sh.Interceptor.LoginInterceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@CrossOrigin
public class MyWebAppConfigurer implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/data/upload/**").addResourceLocations("file:" + "/data/upload/");
        registry.addResourceHandler("/data/dcData/**").addResourceLocations("file:" + "/data/dcData/");
        registry.addResourceHandler("/data/icon/**").addResourceLocations("file:" + "/data/icon/");
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + System.getProperty("user.dir") + "/upload/");
        registry.addResourceHandler("/data/file/**").addResourceLocations("file:" + "/data/file/");
        registry.addResourceHandler("/data/audio/**").addResourceLocations("file:" + "/data/audio/");
        registry.addResourceHandler("/data/video/**").addResourceLocations("file:" + "/data/video/");
        registry.addResourceHandler("/data/Snapshot/**").addResourceLocations("file:" + "/data/Snapshot/");
    }

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor())
//                .addPathPatterns("/user/**")
//                .excludePathPatterns("/user/login")
//                .excludePathPatterns("/user/register").excludePathPatterns("/user/code")
//                .excludePathPatterns("/user/resetPassword").excludePathPatterns("/data/file/");//拦截user下的请求
//    }

//    @Override
//    public void addCorsMappings(CorsRegistry registry) {
//        registry.addMapping("/brand/**")  // 拦截所有的请求
//                .allowedOrigins("http://116.204.81.67:8001")  // 可跨域的域名，可以为 *
////                .allowCredentials(true)
//                .allowedMethods("*")   // 允许跨域的方法，可以单独配置
//                .allowedHeaders("*");  // 允许跨域的请求头，可以单独配置
//    }
}


